import React from "react";
import { Button, message } from "antd";
import { useSelector } from "react-redux";
import { useNavigate } from "react-router-dom";

export default function AddIssueBtn() {
  const navigate = useNavigate();
  const { isLogin } = useSelector((state) => state.user);

  const handleClick = () => {
    // 如果登录则跳转到提问页
    if (isLogin) {
      navigate("/addIssue");
    } else {
      message.warning("请先登录~");
    }
  };

  return (
    <div>
      <Button
        type="primary"
        size="large"
        style={{ width: "100%", height: "35px", marginBottom: "30px" }}
        onClick={handleClick}
      >
        我要发问
      </Button>
    </div>
  );
}
